<template>
	<view>
		<view class="mainpadding4" style="background-color: #ff9341;height: 350rpx;">
			<view class="flexcolumn mainpadding4">
				<view class="xiaobai ershil">总收益</view>
				<view class="xiaobai bigtext fonweight margin_top" style="font-size: 50rpx;">{{userInfo.total_money}}</view>
				<view class="flexbetween margin_top6" style="width: 100%;">
					<view class="xiaobai ershil">团队人数：{{userInfo.team_num}}</view>
					<view class="xiaobai ershil">累计订单数：{{userInfo.order_num}}</view>
				</view>
				<view class="flexbetween margin_top" style="width: 100%;">
					<view class="xiaobai ershil">邀请总数：{{userInfo.yq_num}}</view>
					<view class="xiaobai ershil">今日邀请数：{{userInfo.totay_yq_num}}</view>
				</view>
			</view>
			<view class="mainpadding4 ffffff radius flexaround">
				<view class="flexcolumn">
					<view class="xiaohui ershil">今日收益</view>
					<view class="sanshier margin_top xiaohei fonweight">{{userInfo.todays_money}}</view>
				</view>
				<view class="flexcolumn">
					<view class="xiaohui ershil">昨日收益</view>
					<view class="sanshier margin_top xiaohei fonweight">{{userInfo.yesterday_money}}</view>
				</view>
				<view class="flexcolumn">
					<view class="xiaohui ershil">本月收益</view>
					<view class="sanshier margin_top xiaohei fonweight">{{userInfo.mouth_money}}</view>
				</view>
			</view>
			<view class="topbgc mainpadding" style="padding-bottom: 0;">
				<u-tabs :list="list1" lineColor="#ff9341" :scrollable=false @click="changetab" :activeStyle="{
					    color: '#000000',
					    fontWeight: 'bold',
					    transform: 'scale(1.05)'
					}" :inactiveStyle="{
					            color: '#666666',
								fontWeight: '500',
					            transform: 'scale(1)'
					        }" itemStyle="height: 44px;"></u-tabs>
			</view>
			<view class="flexcolumn" v-if="list.data.length==0">
				<view class="placeholderimage" style="margin-top: 100rpx;"></view>
				<view class="xiaohui margin_top main_size">暂无数据</view>
			</view>
			<template v-if="tabsid==0">
				
				<view class="ffffff mainpadding radius margin_top" v-for="item in list.data" :key="item.id">
					<view class="flexleft">
						<image class="margin_right3" style="width: 120rpx;height: 120rpx; border-radius: 50%;min-width: 120rpx;" :src="item.avatar_text"
							mode=""></image>
							<view class="">
								<view class="xiaohei titletext fonweight">{{item.nickname}}</view>
								<view class="xiaohui strongtext margin_top1">手机号：{{item.mobile}}</view>
								<view class="xiaohui strongtext margin_top1">{{item.rec_time_text}}</view>
							</view>
					</view>
					<view class="mainpadding2s radius margin_top2 ershil" style="background-color: #f1f1f1;">
						<text class="xiaohei">贡献收益：</text>
						<text class="xiaohuang">￥{{item.gx_money}}</text>
					</view>
				</view>
			</template>
			<template v-if="tabsid==1">
				<view class="ffffff mainpadding flexbetween radius margin_top"  v-for="item in list.data" :key="item.id">
					<view class="">
						<view class="ershiba fonweight zhonghei">{{item.memo}}</view>
						<view class="strongtext margin_top1 xiaohui">{{item.createtime_text}}</view>
					</view>
					<view class="sanshier fonweight xiaocheng">{{item.money}}</view>
				</view>
			</template>
		</view>
		<view class="mainpadding gudingdb">
			<view class="bigbtn" @click="jumpurl('/pages_mypage/yaoqinghy')">邀请好友</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				list1: [{
						name: '我的团队',
						value: 0,
					},
					{
						name: '收益明细',
						value: 1,
					}
				],
				tabsid: 0,
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				userInfo:{}
			}
		},
		onLoad() {
			this.userinit()
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this
				let data = {
					page: page || 1,
					limit: 12,
				}
				let url = "/api/user/myteam"
				if(this.tabsid==1){
					this.$set(data,"type",2)
					url = "/api/user/moneyLog"
				}
				httpRequest.request(url, 'GET', data).then(res => {
					uni.stopPullDownRefresh()
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			userinit() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			changetab(e) {
				this.tabsid = e.value
				this.page = 1
				this.list.data = []
				this.init()
			},
		}
	}
</script>

<style>

</style>
